'use strict';

Object.defineProperty(exports, "__esModule", {
    value: true
});

var _extends2 = require('babel-runtime/helpers/extends');

var _extends3 = _interopRequireDefault(_extends2);

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = require('babel-runtime/helpers/createClass');

var _createClass3 = _interopRequireDefault(_createClass2);

var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = require('babel-runtime/helpers/inherits');

var _inherits3 = _interopRequireDefault(_inherits2);

var _react = require('react');

var React = _interopRequireWildcard(_react);

var _antd = require('antd');

var _authCheck = require('../auth-check');

var _authCheck2 = _interopRequireDefault(_authCheck);

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

var ButtonAuth = function (_React$Component) {
    (0, _inherits3['default'])(ButtonAuth, _React$Component);

    function ButtonAuth() {
        (0, _classCallCheck3['default'])(this, ButtonAuth);

        var _this = (0, _possibleConstructorReturn3['default'])(this, (ButtonAuth.__proto__ || Object.getPrototypeOf(ButtonAuth)).apply(this, arguments));

        _this.getButton = function () {
            var _this$props = _this.props,
                children = _this$props.children,
                type = _this$props.type,
                title = _this$props.title,
                buttonicon = _this$props.buttonicon;

            if (type == 'text') {
                return React.createElement(
                    _antd.Button,
                    (0, _extends3['default'])({}, _this.props, { type: 'default', className: 'btn-text' }),
                    children
                );
            } else if (type == 'icon') {
                return React.createElement(
                    _antd.Tooltip,
                    { title: title },
                    React.createElement(
                        _antd.Button,
                        (0, _extends3['default'])({}, _this.props, { type: 'default', className: 'btn-text' }),
                        React.createElement(_antd.Icon, { type: buttonicon }),
                        children
                    )
                );
            } else {
                return React.createElement(
                    _antd.Button,
                    _this.props,
                    children
                );
            }
        };
        return _this;
    }

    (0, _createClass3['default'])(ButtonAuth, [{
        key: 'render',
        value: function render() {
            var _props = this.props,
                check = _props.check,
                storagetype = _props.storagetype;

            if (storagetype && storagetype === "localStorage") {
                return React.createElement(
                    _authCheck2['default'],
                    { check: check, storagetype: 'localStorage' },
                    this.getButton()
                );
            }
            return React.createElement(
                _authCheck2['default'],
                { check: check },
                this.getButton()
            );
        }
    }]);
    return ButtonAuth;
}(React.Component); /**
                     * 带权限校验的Button组件，兼容antd.Button
                     * @Author: ljq
                     * @Date: 2018-10-11 14:23:05
                     */


exports['default'] = ButtonAuth;
module.exports = exports['default'];